package A1_贪心算法;

import java.util.Arrays;

public class LC_452用最少数量的箭引爆气球 {
    public static void main(String[] args){
        int[][] points={{10,16},{2,8},{1,6},{7,12}};
        Arrays.sort(points,(a,b)->{
            if(a[0]>b[0])
                return a[0]-b[0];
            return a[0]-b[0];
        });
        System.out.println(points);
    }
    public int findMinArrowShots(int[][] points) {
        Arrays.sort(points,(a,b) -> Integer.compare(a[0], b[0]));
        int result=1;
        for(int i=1;i<points.length;i++){
            if(points[i][0]>points[i-1][1])
                result++;
            else
                points[i][1]=Math.min(points[i][1],points[i-1][1]);
        }
        return result;
    }
}
